<?php


use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\grid\GridView;
use app\models\Park;
use yii\bootstrap\Modal;
use yii\helpers\Url;
use app\models\Batch;  //批次表  根据该产品的ID在 批次表中查询 肯定是查询到多个记录的次数
use app\models\Croptype; //作物类别表 需要根据所属类别的ID在类别表中将类别名字取出来


\app\assets\AppAsset::register($this);
$this->registerCssFile('@web/css/trace.css');
?>


<?php
  $sql="SELECT * FROM shbb_batch WHERE product_id=1";
   $b_model=Batch::findBySql($sql)->all();

   $i=0;
    foreach($b_model as $model)
    {
        $i++;
    }

?>
    <div id="product-detail-box" style="position:absolute; width:83%;height:800px;left:180px;top:80px;background-image:url(../assets/img/bg.jpg)">
        <!--设置整个布局的div-->
        <?php foreach($products as $model):?>
        <div class='one'style="position:relative; width:800px;height:250px;left:-80px;top:0px;" ><!--设置内部产品的div-->


            <div class='detail-pic'>
                <?=Html::img($model->img, ['alt' => 'My logo', 'width' => '250px','height'=>'200px'])?>
            </div>

            <div class="detail-intro">
                <p><strong><?= $model->name; ?></strong></p>
                <?php
                $sql="SELECT * FROM shbb_batch WHERE product_id=$model->id";
                $b_model=Batch::findBySql($sql)->all();
                $i=0;
                foreach($b_model as $bmodel)
                {
                    $i++;
                }
                $sql="SELECT *FROM shbb_crop_type WHERE id=$model->crop_type_id";  //查找作物类别的id是2的信息
                $type_model=Croptype::findBySql($sql)->one();
                ?>
                <p class="pad_bot2"> 产品简介:  <?= $model->introduction; ?></p>
                <p class="pad_bot2"> 产品所属作物类别:&nbsp&nbsp&nbsp&nbsp<?= $model->crop_type_id; ?></p>
                <p class="pad_bot2"> 产品所属作物:&nbsp&nbsp&nbsp&nbsp<?= $type_model->name; ?></p>
                <p class="pad_bot2"> 评价值:  &nbsp&nbsp&nbsp&nbsp<?= $model->rating_num; ?></p>
                <p class="pad_bot2"> 平均评价值:&nbsp&nbsp&nbsp&nbsp<?= $model->rating_score; ?></p>
                <!--<p class="pad_bot2"> 最新批次建立时间:<?/*=$b_model->BatchBuildTime*/?></p>-->
                <p class="pad_bot2"> 该产品批次建立次数:&nbsp&nbsp&nbsp&nbsp<?= $i; ?></p>
                <?php
                Modal::begin([
                    'header'=>'产品认证信息',
                    'id'=>"modal$model->id",
                    'size'=>'modal-lg',
                ]);
                echo "<div id='modalContent".$model->id."'></div>";
                Modal::end();
                ?>
                <?= Html::a('批次信息',['batch/index','id'=>$model->id], ['class' => 'btn btn-success','style'=>['TEXT-DECORATION'=>'none']])?>
                <?= Html::a('销售信息',['sale/index','id'=>$model->id], ['class' => 'btn btn-success','style'=>['TEXT-DECORATION'=>'none']])?>
                <?= Html::a('认证信息',['authetic/index','id'=>$model->id], ['class' => 'btn btn-success','style'=>['TEXT-DECORATION'=>'none']])?>

            </div>
        </div>
            <div style="clear:both"></div>
                <?php endforeach?>
                <div style="clear:both"></div>
</div>
</body>
</html>